import axios from 'axios';
import apiClient from '@/services/axiosConfig';
import router from '@/router';

export const appointmentApi = async (data) => {

    try {
        const response = await axios.get(`http://localhost:9000/orders/myOrder?userId=${data}`)
        return response.data;
    } catch (error) {
        console.error(error)
    }
}

export const cancelappointmentApi = async (data) => {

    try {
        const response = await axios.get(`http://localhost:9000/orders/cancelOrder?orderId=${data}`)
        return response.data;
    } catch (error) {
        console.error(error)
    }
}

/**
 * 获得医院当天剩余人数
 * @param {*医院ID} hpId 
 * @param {*预约日期} orderDate 
 * @returns 
 */
export const selectDateApi = async (hpId,orderDate) => {

    try {
        const response = await axios.get(`http://localhost:9000/orders/selectDate?hpId=${hpId}&orderDate=${orderDate}`)
        return response.data;
    } catch (error) {
        console.error(error)
    }
}

export const addOrderApi = async (userid,hpid,smid,date) => {

    try {
        const response = await axios.get(`http://localhost:9000/orders/addOrder?userId=${userid}&hpId=${hpid}&setmealId=${smid}&orderDate=${date}`)
        return response.data;
    } catch (error) {
        console.error(error)
    }
}